package com.gitee.srurl.core.dto.result;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author zxw
 * @date 2023/4/29 10:17
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ShortUrlResultDTO implements Serializable {

    @Serial
    private static final long serialVersionUID = 5572748570734923521L;

    /**
     * 原始URL
     */
    private String originUrl;

    /**
     * 短url
     */
    private String shortUrl;

    /**
     * 使用次数 -1 代表不限制
     */
    private Long times;

    /**
     * 剩余次数
     */
    private Long remainTimes;

    /**
     * 是否禁用
     */
    private Boolean disabled;

    /**
     * 过期时间 默认半年
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime expireTime;

    /**
     * 是否成功执行
     */
    @JsonIgnore
    private Boolean success;

    /**
     * 错误消息
     */
    @JsonIgnore
    private String errorMsg;

    /**
     * 创建用户ID
     */
    private Long createId;
}
